package com.yanqu.road.server.cmd.activity.biaoju;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.BiaoJuProto;
import com.yanqu.road.server.cmd.CrossUnionCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.manager.activity.biaoju.CrossBiaoJuActivity;
import com.yanqu.road.server.manager.activity.biaoju.CrossBiaoJuMgr;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.GameProtocol;
import com.yanqu.road.server.protocol.Protocol;
import com.yanqu.road.utils.YanQuMessageUtils;

@Cmd(code = Protocol.C_BIAOJU_REFRESH_ESCORT_LIST, desc = "刷新镖单列表")
public class CrossBiaoJuRefreshEscortListCmd extends CrossUnionCommand {
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        BiaoJuProto.CrossBiaoJuRefreshEscortReqMsg reqMsg = BiaoJuProto.CrossBiaoJuRefreshEscortReqMsg.parseFrom(packet.getBytes());
        CrossBiaoJuActivity activity = CrossBiaoJuMgr.getActivity(reqMsg.getActivityId(), groupId);
        if (activity == null) {
            return;
        }

        BiaoJuProto.CrossBiaoJuRefreshEscortRespMsg.Builder respMsg = BiaoJuProto.CrossBiaoJuRefreshEscortRespMsg.newBuilder();
        respMsg.setActivityId(reqMsg.getActivityId());
        respMsg.setIsCostGoods(reqMsg.getIsCostGoods());
        BiaoJuProto.BiaoJuRefreshEscortListRespMsg.Builder resultMsg = activity.refreshUserWaitTakeList(packet.getPlayerId(), reqMsg.getIsCostGoods());
        respMsg.setRespMsg(resultMsg);
        respMsg.setGuaranteeAmount(activity.getUserGuaranteeRefreshCount(packet.getPlayerId()));
        MessageHelper.sendPacket(serverId, packet.getPlayerId(),
                YanQuMessageUtils.buildMessage(GameProtocol.S_BIAOJU_REFRESH_ESCORT_LIST_CROSS_BACK, respMsg));
    }

    @Override
    public void sendData() {

    }
}
